<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <h:head>
        <link rel="stylesheet" type="text/css" href="/MeteoCal/resources/css/application.css" />
        <link rel="stylesheet" type="text/css" href="/MeteoCal/resources/css/header.css" />
        <link rel="stylesheet" type="text/css" href="/MeteoCal/resources/css/messageBox.css" />
        <ui:insert name="head" >
            <title>MeteoCal</title>
        </ui:insert>
    </h:head>
    <h:body>
        <div id="page">
            <div id="header">
                <div id="searchBanner">
                    <div id="miniLogoBox">
                        <p:link outcome="home" title="MeteoCal Home">
                            <p:graphicImage value="/resources/icons/meteo_calendar.png" height="45px" />
                        </p:link>
                    </div>
                    <div id="searchBox">
                        <h:form>
                            <h:panelGrid id="searchGrid" columns="2">
                                <p:inputText value="#{searchBean.keyword}" />
                                <p:commandButton value="Search" action="#{searchBean.search()}" update="searchGrid" />
                            </h:panelGrid>
                        </h:form>
                    </div>
                </div>
                <div id="personalBox">
                    <div id="invitationLink">
                        <p:link outcome="invitationList" title="Go to Invitation List">
                            <p:graphicImage value="/resources/icons/notepad_2_icon.png" height="48px" />
                        </p:link>
                    </div>
                    <div id="userBox">
                        <div id="usernameBox">
                            <p:link value="#{userBean.currentUser.username}"
                                    outcome="personalData" style="color: lime;" />
                        </div>
                        <div id="logoutBox">
                            <p:commandLink value="Logout" action="#{loginBean.logout()}" style="color: lime;" />
                        </div>
                    </div>
                </div>
            </div>
            <div id="main">
                <div id="leftBar">
                    <div id="msgBoxTitle">
                        <p:outputPanel>
                            <p:outputLabel value="Messages" />
                        </p:outputPanel>
                    </div>
                    <div id="messageBox">
                        <p:panelGrid>
                            <c:forEach items="#{userBean.loggedUserNotifications}" var="notification">
                                <div>
                                    <h:link value="Notification: #{notification.notificationType.toLowerCase()}" outcome="notification">
                                        <f:param name="eventId" value="#{notification.notificationPK.eventId}" />
                                        <f:param name="participant" value="#{notification.notificationPK.participantUsername}" />
                                        <f:param name="timestamp" value="#{notification.notificationPK.timestamp.time}" />
                                    </h:link>
                                </div>
                            </c:forEach>
                            <c:forEach items="#{userBean.loggedUserInvitations}" var="invitation">
                                <div>
                                    <h:link value="Invitation: #{invitation.title}" outcome="invitation">
                                        <f:param name="sender" value="#{invitation.invitationPK.senderUsername}" />
                                        <f:param name="receiver" value="#{invitation.invitationPK.receiverUsername}" />
                                        <f:param name="eventId" value="#{invitation.invitationPK.eventId}" />
                                    </h:link>
                                </div>
                            </c:forEach>
                            <c:forEach items="#{weatherAlertBean.weatherAlerts}" var="alert">
                                <h:link value="Weather Alert for #{alert.event.name}" outcome="weatherAlert">
                                    <f:param name="id" value="#{alert.id}" />
                                </h:link>
                            </c:forEach>
                        </p:panelGrid>
                    </div>
                </div>
                <div class="contentPage">
                    <ui:insert name="content">This should not appear...</ui:insert>
                </div>
            </div>
        </div>
    </h:body>
</html>

